package com.yyk.yykywd.ui.home;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Administrator on 2019/1/26 0026.
 */

public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<String> tabTitls;
    private List<Fragment> fragments;

    public SimpleFragmentPagerAdapter(FragmentManager fm, List<String> tabTitls, List<Fragment> fragments) {
        super(fm);
        this.tabTitls = tabTitls;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return tabTitls.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabTitls.get(position).toString();
    }

    //防止fragment自动销毁
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        //super.destroyItem(container, position, object);
    }
}
